/* * Graph 3: Urban Water Access Change, Model 5 */ #delimit ;use "/India_timeseries_final _with ipolate_new.dta";cd "/figs/";/*     ****************************************************************  *;*     Estimate Model: Y = b0 + b1X + b2Z + b3XZ + b4Controls + epsilon  *;*     ****************************************************************  */xi: xtpcse _growth_urban_accesstowater _fdiiiasageofgdpreliablerscrore  _popgrowth _lnurban _lnpercapitagdpcurrent19992000 _diiiiasageofgdpallinclusiverscr _growthgsdpatcurrentprices _i2percentageofscst _l2fdigdpreliablei2percentscst _lngross_cropped_area excess_rainfall_20pct  i.id i.year, pairwise corr (psar1);/*     ****************************************************************  *;*       Generate the values of Z for which you want to calculate the    *;*       marginal effect (and standard errors) of X on Y.                *;*     ****************************************************************  */generate MV=((_n-1)/1); /* go row by row and generate new zero-indexed index MV */replace  MV=. if _n>89; /* empty if in observation row > 88 *//*     ****************************************************************  *;*       Grab elements of the coefficient and variance-covariance matrix *;*       that are required to calculate the marginal effect and standard *;*       errors.                                                         *;*     ****************************************************************  */matrix b=e(b); /* coefficient vector */matrix V=e(V); /* variance-covariance matrix of the estimator */ scalar b1=b[1,1]; /* l2.fdiiiasageofgdpreliablerscrore */scalar b3=b[1,8]; /* l2fdigdpreliablepercentscst */scalar varb1=V[1,1];scalar varb3=V[8,8];scalar covb1b3=V[1,8];scalar list b1 b3 varb1 varb3 covb1b3;/*     ****************************************************************  *;*       Calculate the marginal effect of X on Y for all MV values of    *;*       the modifying variable Z.                                       *;*     ****************************************************************  */gen conb=b1+b3*MV if _n<89;/*     ****************************************************************  *;*       Calculate the standard errors for the marginal effect of X on Y *;*       for all MV values of the modifying variable Z.                  *;*     ****************************************************************  */gen conse=sqrt(varb1+varb3*(MV^2)+2*covb1b3*MV) if _n<89;/*     ****************************************************************  *;*       Generate upper and lower bounds of the confidence interval.     *;*       Specify the significance of the confidence interval.            *;*     ****************************************************************  */gen a=1.64*conse; gen uppera=conb+a; gen lowerb=conb-a;/*     ****************************************************************  *;*       Graph the marginal effect of X on Y across the desired range of *;*       the modifying variable Z.  Show the confidence interval.        *;*     ****************************************************************  */graph twoway line conb   MV, clwidth(medium) clcolor(blue) clcolor(black)        ||   line upper  MV, clpattern(longdash) clwidth(thin) clcolor(blue)        ||   line lower  MV, clpattern(longdash) clwidth(thin) clcolor(blue)        ||   ,                xlabel(0 (10) 90, labsize(2.5))               ylabel(-32 (4) 0,  labsize(2))                          legend(col(1) order(1 2) label(1 "Marginal Effect of FDI Inflows")                                       label(2 "90% Confidence Interval")                                       label(3 " "))             yline(0, lcolor(black))                title("Conditional Coefficient of FDI Inflows on Change in Water Access", size(4))             subtitle(" " "DV: Growth in Urban Water Access" " ", size(3))             xtitle( "Percentage of Population belonging to SCST", size(3)  )             xsca(titlegap(2))             ysca(titlegap(2))             ytitle("Conditional Coefficient of FDI Inflows", size(3))             scheme(s2mono) graphregion(fcolor(white));   /* ***REVISED CODE***  graph twoway line conb   MV ||   line upper  MV, lpattern(dash) lcolor(blue) ||   line lower  MV, lpattern(dash) lcolor(blue) scheme(s2mono) graphregion(fcolor(white)) yline(0) ///             xlabel(0 (10) 90, labsize(2.5)) ytitle("Conditional Coefficient of FDI Inflows", size(3)) ///			 title("Conditional Effect of FDI on Changes in Water Access", size(4))  ///			 xtitle( "Percentage of Population belonging to SCST", size(3)  ) xscale(titlegap(2)) yscale(titlegap(2)) ///			 legend(col(1) order(1 2) label(1 "Marginal Effect of FDI Inflows") label(2 "90% Confidence Interval") label(3 " "))			*//*     ****************************************************************  *;*                 Figure can be saved in a variety of formats.          *;*     ****************************************************************  */graph export graph_3_urban_water_access.tif, width(1000) replace; /* translate @Graph figure1.wmf;     *;*     ****************************************************************  *;*                                   THE END                             *;*     ****************************************************************  *//*log close; */clear;exit;